package com.houweishi.module.receipt.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.receipt.domain.BizReceiptProduct;
import com.houweishi.module.receipt.service.IBizReceiptProductService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 入库产品Controller
 * 
 * @author houweishi
 * @date 2023-02-25
 */
@RestController
@RequestMapping("/module/receiptproduct")
public class BizReceiptProductController extends BaseController
{
    @Autowired
    private IBizReceiptProductService bizReceiptProductService;

    /**
     * 查询入库产品列表
     */
    @PreAuthorize("@ss.hasPermi('module:receiptproduct:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizReceiptProduct bizReceiptProduct)
    {
        startPage();
        List<BizReceiptProduct> list = bizReceiptProductService.selectBizReceiptProductList(bizReceiptProduct);
        return getDataTable(list);
    }

    /**
     * 导出入库产品列表
     */
    @PreAuthorize("@ss.hasPermi('module:receiptproduct:export')")
    @Log(title = "入库产品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizReceiptProduct bizReceiptProduct)
    {
        List<BizReceiptProduct> list = bizReceiptProductService.selectBizReceiptProductList(bizReceiptProduct);
        ExcelUtil<BizReceiptProduct> util = new ExcelUtil<BizReceiptProduct>(BizReceiptProduct.class);
        util.exportExcel(response, list, "入库产品数据");
    }

    /**
     * 获取入库产品详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:receiptproduct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizReceiptProductService.selectBizReceiptProductById(id));
    }

    /**
     * 新增入库产品
     */
    @PreAuthorize("@ss.hasPermi('module:receiptproduct:add')")
    @Log(title = "入库产品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizReceiptProduct bizReceiptProduct)
    {
        return toAjax(bizReceiptProductService.insertBizReceiptProduct(bizReceiptProduct));
    }

    /**
     * 修改入库产品
     */
    @PreAuthorize("@ss.hasPermi('module:receiptproduct:edit')")
    @Log(title = "入库产品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizReceiptProduct bizReceiptProduct)
    {
        return toAjax(bizReceiptProductService.updateBizReceiptProduct(bizReceiptProduct));
    }

    /**
     * 删除入库产品
     */
    @PreAuthorize("@ss.hasPermi('module:receiptproduct:remove')")
    @Log(title = "入库产品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizReceiptProductService.deleteBizReceiptProductByIds(ids));
    }
}
